package com.example.smart.adapter.home

import android.app.Activity
import android.view.LayoutInflater
import android.view.ViewGroup
import com.example.lib.extend.setOnDoubleClickListener
import com.example.smart.R
import com.example.smart.base.adapter.BaseRecyclerAdapter
import com.example.smart.base.adapter.BaseViewHolder
import com.example.smart.databinding.ItemVaccinesBinding
import com.example.smart.utils.DisplayUtils

class VaccinesAdapter(val activity: Activity) : BaseRecyclerAdapter<ItemVaccinesBinding, String>(activity) {

    init {
        updateList(context.resources.getStringArray(R.array.vaccines_list).toMutableList())
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<ItemVaccinesBinding> {
        return BaseViewHolder(ItemVaccinesBinding.bind(LayoutInflater.from(context)
            .inflate(R.layout.item_vaccines, parent, false)))
    }

    override fun onBindView(itemView: ItemVaccinesBinding, bean: String, position: Int) {
        itemView.ItemText.text = bean
        itemView.root.setOnDoubleClickListener {
            DisplayUtils.toVaccinesDetails(activity)
        }
    }
}